// https://leetcode.cn/problems/longest-increasing-subsequence/submissions/545458005/
class Solution {
public:
    int lengthOfLIS(vector<int>& nums) {
        int n = nums.size();
        int* dp = new int[n]; //前i个数字里，最长递增子序列的长度
        int ans = 1;
        for (int i = 0; i < n; i++) {
            dp[i] = 1;
            for (int j = 0; j<n; j++) { //前面的结果
                if (nums[i] > nums[j]) {
                    //数字i满足递增，所以答案可以从前面的已知量推得
                    //
                    dp[i] = max(dp[i], dp[j]+1);
                    ans = max(dp[i], ans);
                }              
            }
        }
        return ans;
    }
};